import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import './assets/main.css'

// Import Element Plus global styles
import 'element-plus/dist/index.css'
import pinia from './stores'

// v-md-editor配置
import VueMarkdownEditor from '@kangc/v-md-editor';
import '@kangc/v-md-editor/lib/style/base-editor.css';
import VMdPreview from '@kangc/v-md-editor/lib/preview';
import '@kangc/v-md-editor/lib/style/preview.css';
import githubTheme from '@kangc/v-md-editor/lib/theme/github.js';
import '@kangc/v-md-editor/lib/theme/style/github.css';

// 代码高亮
import hljs from 'highlight.js';
// 按需引入语言包
import 'highlight.js/lib/languages/javascript';
import 'highlight.js/lib/languages/java';
import 'highlight.js/lib/languages/python';
import 'highlight.js/lib/languages/bash';
import 'highlight.js/lib/languages/css';
import 'highlight.js/lib/languages/json';
import 'highlight.js/lib/languages/sql';
import 'highlight.js/lib/languages/xml';

// 引入复制代码插件
import createCopyCodePlugin from '@kangc/v-md-editor/lib/plugins/copy-code/index';
import '@kangc/v-md-editor/lib/plugins/copy-code/copy-code.css';

// 代码行号插件
import createLineNumberPlugin from '@kangc/v-md-editor/lib/plugins/line-number/index';


// 设置主题
VueMarkdownEditor.use(githubTheme, {
  Hljs: hljs,
});
VMdPreview.use(githubTheme, {
  Hljs: hljs,
});

// 使用插件
VueMarkdownEditor.use(createCopyCodePlugin());
VMdPreview.use(createCopyCodePlugin());
VueMarkdownEditor.use(createLineNumberPlugin());
VMdPreview.use(createLineNumberPlugin());

// 读取环境变量
console.log('当前环境:', import.meta.env.MODE)
console.log('API URL:', import.meta.env.VITE_API_URL)

// Create and mount the app
const app = createApp(App)
app.use(router)
// 使用 Pinia
app.use(pinia);
// 使用 v-md-editor
app.use(VueMarkdownEditor);
app.use(VMdPreview);

app.mount('#app')
